//
//  ZJStudyCoureFooterView.m
//  LovingPartyBuilding
//
//  Created by ZJ on 2017/5/16.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ZJStudyCoureFooterView.h"

@interface ZJStudyCoureFooterView ()

/** 评论输入框 */
@property (nonatomic, strong) UIButton *commentTextButton;
/** 评论按钮 */
@property (nonatomic, strong) UIButton *commentButton;
/** 笔记按钮 */
@property (nonatomic, strong) UIButton *noteButton;
/** 分割线 */
@property (nonatomic, strong) UILabel *spaceLine;

@end

@implementation ZJStudyCoureFooterView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addSubview:self.commentTextButton];
        [self addSubview:self.commentButton];
//        [self addSubview:self.noteButton];
        [self addSubview:self.collectButton];
        [self addSubview:self.spaceLine];
    }
    return self;
}


#pragma mark - 点击事件
//评论输入框
- (void)action_commentTextButton:(UIButton *)sender{
    if (self.delegate) {
        [self.delegate ZJStudyCoureFooterViewDelegate_commentTextButtonClick];
    }
}
//评论按钮
- (void)action_commentButton:(UIButton *)sender{
    if (self.delegate) {
        [self.delegate ZJStudyCoureFooterViewDelegate_commentButtonClick];
    }
}
//笔记按钮
- (void)action_noteButton:(UIButton *)sender{
    if (self.delegate) {
        [self.delegate ZJStudyCoureFooterViewDelegate_noteButtonClick];
    }
}

//收藏按钮
- (void)action_collectButton:(UIButton *)sender{
    if (self.delegate) {
        [self.delegate ZJStudyCoureFooterViewDelegate_collectButtonClick];
    }
}

- (void)setButtonUI:(UIButton *)button{

    button.titleEdgeInsets = UIEdgeInsetsMake(25 * [UIScreen zj_screenHScale], -button.imageView.image.size.width, 0.0, 0.0);
    button.imageEdgeInsets = UIEdgeInsetsMake(- 15 * [UIScreen zj_screenHScale], (button.bounds.size.width - button.imageView.image.size.width)/2, 0.0,(button.bounds.size.width - button.imageView.image.size.width)/2);
}

#pragma mark - Setter
#pragma mark - Getters

- (UIButton *)commentTextButton{
    if (_commentTextButton == nil){
        _commentTextButton = [[UIButton alloc]initWithFrame:CGRectMake(18 * [UIScreen zj_screenWScale], 10, 213 * [UIScreen zj_screenWScale], 29)];
        _commentTextButton.backgroundColor = [UIColor zj_colorWithHexString:@"f3f3f3"];
        _commentTextButton.layer.cornerRadius = 8 ;
        _commentTextButton.titleLabel.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
        [_commentTextButton setTitle:@"期待您的评论" forState:UIControlStateNormal];
        [_commentTextButton setTitleColor:[UIColor zj_colorWithHexString:@"777777"] forState:UIControlStateNormal];
        [_commentTextButton addTarget:self action:@selector(action_commentTextButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _commentTextButton;
}

- (UIButton *)commentButton{
    if (_commentButton == nil){
        _commentButton = [[UIButton alloc]initWithFrame:CGRectMake(self.commentTextButton.right + 18 * [UIScreen zj_screenWScale], 0, ([UIScreen zj_screenWith] - self.commentTextButton.right - 36 * [UIScreen zj_screenWScale]) / 2, 49)];
        [_commentButton setImage:[UIImage imageNamed:@"learn_question_com"] forState:UIControlStateNormal];
        [_commentButton setImage:[UIImage imageNamed:@"learn_question_com"] forState:UIControlStateHighlighted];
        [_commentButton setTitle:@"评论" forState:UIControlStateNormal];
        [_commentButton setTitleColor:[UIColor zj_colorWithHexString:@"777777"] forState:UIControlStateNormal];
        _commentButton.titleLabel.font = [UIFont systemFontOfSize:10];
        [_commentButton addTarget:self action:@selector(action_commentButton:) forControlEvents:UIControlEventTouchUpInside];
        [self setButtonUI:_commentButton];
    }
    return _commentButton;
}

- (UIButton *)noteButton{
    if (_noteButton == nil){
        _noteButton = [[UIButton alloc]initWithFrame:CGRectMake(self.commentButton.right, 0, self.commentButton.width, 49)];
        [_noteButton setImage:[UIImage imageNamed:@"learn_source_thingking_d"] forState:UIControlStateNormal];
        [_noteButton setImage:[UIImage imageNamed:@"learn_source_thingking_d"] forState:UIControlStateHighlighted];
        [_noteButton setTitle:@"笔记" forState:UIControlStateNormal];
        [_noteButton setTitleColor:[UIColor zj_colorWithHexString:@"777777"] forState:UIControlStateNormal];
        _noteButton.titleLabel.font = [UIFont systemFontOfSize:10];
        [_noteButton addTarget:self action:@selector(action_noteButton:) forControlEvents:UIControlEventTouchUpInside];
        [self setButtonUI:_noteButton];
    }
    return _noteButton;
}

- (UIButton *)collectButton{
    if (_collectButton == nil){
        _collectButton = [[UIButton alloc]initWithFrame:CGRectMake(self.commentButton.right, 0, self.commentButton.width, 49)];
        [_collectButton setImage:[UIImage imageNamed:@"learn_question_shoucang_d"] forState:UIControlStateNormal];
        [_collectButton setImage:[UIImage imageNamed:@"learn_question_shoucang_d"] forState:UIControlStateHighlighted];
        [_collectButton setImage:[UIImage imageNamed:@"learn_question_shoucang_h"] forState:UIControlStateSelected];
        [_collectButton setTitle:@"收藏" forState:UIControlStateNormal];
        [_collectButton setTitleColor:[UIColor zj_colorWithHexString:@"777777"] forState:UIControlStateNormal];
        _collectButton.titleLabel.font = [UIFont systemFontOfSize:10];
        [_collectButton addTarget:self action:@selector(action_collectButton:) forControlEvents:UIControlEventTouchUpInside];
        [self setButtonUI:_collectButton];
    }
    return _collectButton;
}
- (UILabel *)spaceLine{
    if (_spaceLine == nil){
        _spaceLine = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.width, 0.5)];
        _spaceLine.backgroundColor = [UIColor zj_colorWithHexString:@"dedede"];
    }
    return _spaceLine;
}
@end
